import { createRouter, createWebHistory } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'


export const constantRoutes = [{
    path: '/',
    name: 'index',
    component: () =>
        import ('@/views/index'),
    meta: {
        title: "头像合成"
    }
}]

const routerHistory = createWebHistory()
const router = createRouter({
    scrollBehavior: () => ({ y: 0 }),
    history: routerHistory,
    routes: constantRoutes
})

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher
}

/**进度条配置 start */
NProgress.configure({ showSpinner: false })
router.beforeEach(async(to, from, next) => {
    NProgress.start()
    next()
})

router.afterEach(() => {
    NProgress.done()
})
export default router